package org.example.demo7;/*
 *@ 代阳敲的专属代码
 **/

import java.util.*;

public class Preson<E,T> {
    public  E name;
    public  T age;

    public Preson(E name, T age) {
        this.name = name;
        this.age = age;
    }
    public Preson() {

    }

    public E getName() {
        return name;
    }

    public void setName(E name) {
        this.name = name;
    }

    public T getAge() {
        return age;
    }

    public void setAge(T age) {
        this.age = age;
    }

    public void test1( ){
        Set<Preson<String,Integer>> set=new HashSet<>();
        set.add(new Preson<>("xiaolv",11));
        set.add(new Preson<>("xiaowang",12));
        set.add(new Preson<>("xiaohei",13));


    }
    public void test2( ){
        List<Integer> list=new ArrayList<>();
        List<int []> list1=new ArrayList<>();
        List<A> list2=new ArrayList<>();
        list2.add(new A());
        list2.add(new B());
    }
    public static void main(String[] args) {
//        Preson <String,Integer> preson=new Preson<>();
//        preson.setAge(11);
//        preson.setName("11");

    }
}

class A {

}
class B extends A {

}
class Tiger <T,E,M> {
    String name;
    T t;
    E e;
    M m;
    T [] arr;

    public Tiger(String name, T t, E e, M m) {
        this.name = name;
        this.t = t;
        this.e = e;
        this.m = m;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public T getT() {
        return t;
    }

    public void setT(T t) {
        this.t = t;
    }

    public E getE() {
        return e;
    }

    public void setE(E e) {
        this.e = e;
    }

    public M getM() {
        return m;
    }

    public void setM(M m) {
        this.m = m;
    }


    public static void main(String[] args) {
        Tiger<String,Integer,Double> tiger=new Tiger<>("tiger","string",12,12.0);

    }
}

interface USB<T,R>{
    R get(T t);
    void hide(R r);
}
class C implements USB<String,Integer>{
    @Override
    public Integer get(String s) {
        return s.length();
    }

    @Override
    public void hide(Integer integer) { System.out.println(integer);}
}
class D implements USB{
    @Override
    public Object get(Object o) {
        return o;
    }

    @Override
    public void hide(Object o) {
        System.out.println(o);
    }
}
interface AA extends USB{

}
class E implements AA {
    @Override
    public Object get(Object o) {
        return o;
    }

    @Override
    public void hide(Object o) {
        System.out.println(o);
    }
}
class Test{
    public <T,R> T test(T t,R r){
       return t;
    }

    public static void main1(String[] args) {
        Test test1=new Test();
        System.out.println(test1.test("1ee", "1e"));

    }
}
 class CustomMethodGenericExercise {
    public static void main(String[] args) {
//T->String, R->Integer, M->Double
        Apple<String, Integer, Double> apple = new Apple<>();
        apple.fly(10);//10 会被自动装箱 Integer10, 输出 Integer
        apple.fly(new Dog1());//Dog
    }
}
class Apple<T, R, M> {//自定义泛型类
    public <E> void fly(E e) { //泛型方法
        System.out.println(e.getClass().getSimpleName());
    }
    //public void eat(U u) {}//错误，因为 U 没有声明
    public void run(M m) {
    } //ok
}
class Dog1 {
    public static void main(String[] args) {
        List<Object> list = new ArrayList<>();

    }
}